<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Tabib Apps web | Admin Dashboard Template</title>
    <!-- Base Styling  -->
    <link rel="stylesheet" href="static/css/fonts.css">
    <link rel="stylesheet" href="static/css/style.css">
</head>

<body>
<div id="main-wrapper" class="show">


    <!-- start logo components -->
    <div class="nav-header">
        <div class="brand-logo">
            <a href="index.html"> <img class="logo-tabib" src="static/picture/download.png" alt=""></a>
            <a href="index.html"><img class="brand-title" src="static/picture/logo.png" alt=""></a>
        </div>
    </div>
    <!-- End logo components -->


    <!-- start section sidebar -->
    <aside class="left-panel nicescroll-box">
        <nav class="navigation">
            <ul class="list-unstyled main-menu">
                <li class="has-submenu">
                    <a href="index.html">
                        <i class="fas fa-th-large"></i>
                        <span class="nav-label">首页</span>
                    </a>
                </li>
                <li class="has-submenu">
                    <a href="#" class="has-arrow mm-collapsed">
                        <i class="fas fa-user-md"></i>
                        <span class="nav-label">医生</span>
                    </a>
                    <ul class="list-unstyled mm-collapse">
                        <li><a href="new-patient.html">查看患者信息</a></li>
                        <li><a href="all-patients.html">所有患者</a></li>
                    </ul>
                </li>
                <li class="has-submenu">
                    <a href="#" class="has-arrow mm-collapsed">
                        <i class="fas fa-book-medical"></i>
                        <span class="nav-label">处方</span>
                    </a>
                    <ul class="list-unstyled mm-collapse">
                        <li><a href="new-prescription.html">新处方</a></li>
                        <li><a href="allPrescriptions.html">所有处方</a></li>
                    </ul>
                </li>
                <li class="has-submenu">
                    <a href="calendars.html">
                        <i class="fas fa-calendar-alt"></i>
                        <span class="nav-label">排班时间</span>
                    </a>
                </li>
            </ul>
        </nav>
        <div class="sidebar-widgets">
            <div class="top-sidebar box-shadow mx-25 m-b-30 p-b-20 text-center">
                <a href="new-appointment.html">
                    <img src="static/picture/appointement.svg" class="side-img" alt="img">
                </a>
                <a href="#">
                    <h4 class="text-primary mb-0">Make an Appointments</h4>
                </a>
            </div>
            <div class="copyright text-center">
                <p class="mb-0"> Tabib Dashboard</p>
                <p class="mb-0"> © 2021 </p>
            </div>
        </div>
    </aside>
    <!-- End section sidebar -->


    <!-- start section header -->
    <div class="header">
        <header class="top-head container-fluid">
            <div class="nav-control">
            </div>
            <div class="header-right">
                <div class="fullscreen notification_dropdown">
                    <div class="full">
                        <a class="text-dark" href="#!" onclick="javascript:toggleFullScreen()">
                            <i class="fas fa-expand"></i>
                        </a>
                    </div>
                </div>
                <div class="notification_dropdown">
                    <div class="cart-wrapper">
                        <div class="cart-icon">
                            <a class="cart-control" href="#">
                                <i class="fas fa-bell"></i>
                                <div class="pulse-css"></div>
                            </a>
                        </div>
                        <div class="cart-dropdown-form dropdown-container">
                            <div class="form-content">
                                <div class="widget-media main-scroll nicescroll-box">
                                    <ul class="timeline">
                                        <li>
                                            <h6 class="mb-0">通知</h6>
                                        </li>
                                        <li>
                                            <div class="timeline-panel">
                                                <div class="media mr-2">
                                                    <img alt="image" src="static/picture/1.jpg">
                                                </div>
                                                <div class="media-body">
                                                    <h6 class="mb-1 ">Incoming Message</h6>
                                                    <small class="d-block">29 July 2020 - 02:26 PM</small>
                                                </div>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                                <a class="all-notification btn btn-primary" href="#">
                                    查看所有通知
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="my-account-wrapper">
                    <div class="account-wrapper">
                        <div class="account-control">
                            <a class="login header-profile" href="#" title="Sign in">
                                <div class="header-info">
                                    <span id="nickname">Dr Roberts</span>
                                    <small>医生</small>
                                </div>
                                <img src="static/picture/client.jpg" alt="people" id="img">
                            </a>
                            <div class="account-dropdown-form dropdown-container">
                                <div class="form-content">
                                    <a href="chat.html">
                                        <i class="far fa-user"></i>
                                        <span class="ml-2">在线聊天</span>
                                    </a>
                                    <a href="login.html">
                                        <i class="fas fa-sign-in-alt"></i>
                                        <span class="ml-2">退出 </span>
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </header>
    </div>
    <!-- End section header -->


    <!-- start section content -->
    <div class="content-body">
        <div class="warper container-fluid">
            <div class="row page-titles mx-0">
                <div class="col-lg-12 p-md-0">
                    <h4 class="text-primary">早上好<span class="names">Dr Roberts</span></h4>
                </div>
            </div>
            <div class="new-patients main_container">
                <div class="row">
                    <div class="col-md-12">
                        <div class="card shadow">
                            <div class="card-header">
                                <h4 class="card-title">预约清单 | 2021年4月8日</h4>
                            </div>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table id="example1" class="display nowrap">
                                        <thead>
                                        <tr>
                                            <th>时间</th>
                                            <th>日期</th>
                                            <th>病人</th>
                                            <th>电话</th>
                                            <th>状态</th>
                                            <th>是否已叫号</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <!--<tr>
                                            <td>
                                                07:00
                                            </td>
                                            <td>01 Jun 2021</td>
                                            <td> Michael R Sheets </td>
                                            <td> 1468 Selah Way - Rabat</td>
                                            <td>833 - 844 - 0100</td>
                                            <td class="text-start">
                                                <span class="badge badge-primary">Start appt</span>
                                            </td>
                                            <td>
                                                <a class='mr-4 check'>
                                                    <span class='fas fa-check'></span>
                                                </a>
                                                <a class='delet'>
                                                    <span class='fas fa-trash-alt'></span>
                                                </a>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                07:30
                                            </td>
                                            <td>02 Jun 2021</td>
                                            <td> Eric J Lane</td>
                                            <td>1468 Selah Way - Agadir</td>
                                            <td>833 - 844 - 0100</td>
                                            <td class="text-start"> <span class="badge badge-primary">Start
                                                            appt</span>
                                            </td>
                                            <td>
                                                <a class='mr-4 check'>
                                                    <span class='fas fa-check'></span>
                                                </a>
                                                <a class='delet'>
                                                    <span class='fas fa-trash-alt'></span>
                                                </a>
                                            </td>
                                        </tr>
                                        <tr>

                                            <td>
                                                08:00
                                            </td>
                                            <td>03 Jun 2021</td>
                                            <td> Pamela R Matheney </td>
                                            <td>1468 Selah Way - Casablanca</td>
                                            <td>833 - 844 - 0100</td>
                                            <td class="text-start"> <span class="badge badge-primary">Start
                                                            appt</span>
                                            </td>
                                            <td>
                                                <a class='mr-4 check'>
                                                    <span class='fas fa-check'></span>
                                                </a>
                                                <a class='delet'>
                                                    <span class='fas fa-trash-alt'></span>
                                                </a>
                                            </td>
                                        </tr>-->
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- End section content -->


    <!-- start section footer -->
    <div class="footer">
        <div class="copyright">
            <p class="mb-0">Copyright &copy; 2021.Company name All rights reserved.<a target="_blank" href="http://www.cssmoban.com/">&#x7F51;&#x9875;&#x6A21;&#x677F;</a></p>
        </div>
    </div>
    <!-- End section footer -->


</div>


<!-- JQuery v3.5.1 -->
<script src="static/js/jquery.min.js"></script>

<script src="static/js/jquery-3.6.0.js"></script>

<!-- popper js -->
<script src="static/js/popper.min.js"></script>

<!-- Bootstrap -->
<script src="static/js/bootstrap.js"></script>

<!-- Moment -->
<script src="static/js/moment.min.js"></script>

<!-- Date Range Picker -->
<script src="static/js/daterangepicker.min.js"></script>

<!-- Datatable -->
<script src="static/js/jquery.dataTables.min.js"></script>
<script src="static/js/init-tdatatable.js"></script>

<!-- Chart js -->
<script src="static/js/Chart.min.js"></script>
<script src="static/js/charts-custom.js"></script>

<!-- Main Custom JQuery -->
<script src="static/js/toggleFullScreen.js"></script>
<script src="static/js/main.js"></script>

</body>
<script>


    $(function () {
        let pageNum = 1 ;
        let pageSize =$("select[name=example1_length]").val();

        orderShow();
        function orderShow(){
            $.ajax({
                type:"get",
                url:"/order/detailpage",
                data:{pageNum,
                    pageSize
                },
                datatype:"json",
                success:(result,xhr,status)=>{
                    let  concat = "";
                    let  concat1 = "";
                    let  concat2 = "";
                    let  concat3 = "";




                    concat +=` <h4 class="card-title">预约清单 | ${result.data.list[0].orderTime.substring(0,10)}</h4>`;


                    concat1 +=`早上好<span class="names">${result.data.list[0].doctor.doctorName}</span>`;
                   /* concat3 +=`<label>搜索:<input type="search" class="" placeholder="" aria-controls="example1"></label>`;*/
                    if (result!=null){
                        $.each(result.data.list, function (index, obj) {
                            concat2 += `<tr>
                                            <td>
                                                ${obj.orderTime.substring(11, 16)}
                                            </td>
                                            <td>${obj.orderTime.substring(0, 10)}</td>
                                            <td>${obj.patient.patientName}</td>
                                            <td>${obj.patient.phone}</td>`;
                                          if(obj.status=='2'){//完成转态
                                              concat2 +=

                                                  `<td class="text-start">
                                                <a class="badge badge-primary" style="color: #1c1f23">已完成
                                            </td>
                                            <td>
                                            <a class='mr-4 check'>
                                                    <span class='fas fa-check-circle'  style="color: red; ">已叫号</span>

                                                </a>

                                            </td>
                                        </tr>`;
                                          }else if(obj.status=='1'){//未开始状态
                                        concat2 += `<td class="text-start">
                                                <a class="badge badge-primary" href="new-patient.html?patientId=${obj.patient.patientId}&orderId=${obj.orderId}">开始就诊
                                            </td>
                                            <td><a class='mr-4 check'>
                                                      <span class='fas fa-check-circle'  >未叫号</span>
                                                    </a>

                                            </td>
                                        </tr>`

                                          }else if (obj.status=='3'){//正在进行状态
                                              concat2 += `<td class="text-start">
                                                <a class="badge badge-primary" href="http://localhost:8080/order/updateOrderStatus?orderId=${obj.orderId}&status=${obj.status}">点击完成
                                            </td>
                                            <td><a class='mr-4 check'>
                                                      <span class='fas fa-check-circle'  >正在进行</span>
                                                    </a>

                                            </td>
                                        </tr>`

                                          }


                        })
                    }




                    // 更新DOM元素
                    $(".card-header").html(concat);
                    $(".text-primary").html(concat1);
                    $("#example1 tbody").html(concat2);
                    /*$(".example1_filter").html(concat3);*/


                },
                error:()=>{
                    alert("异步请求失败");
                }

            });

        }
    })
    /*function startAppt(){
        $.ajax({
            type:"get",
            url:"/order/detailpage",
            data:{pageNum,
                pageSize
            },
            datatype:"json",
            success:(result,xhr,status)=>{
            },
            error:()=>{
                alert("异步请求失败");
            }

        });

    }*/


    /*function query(name){
        const search = location.search.substr(1);
        const p = new URLSearchParams(search);
        return p.get(name);
    }
    console.log(query('a'));
    console.log(query('b'));*/









</script>
<script>
    $(document).ready(function () {
        $.ajax({
            type: "GET",
            url: "/doctor/session",
            contentType: "application/x-www-form-urlencoded",
            dataType: "json"
        }).done((result)=>{
            if (result.data!=null){

                //设置登录用户昵称
                $("#nickname").text(result.data.doctorName);
                $("#img").attr("src",result.data.image);

                $(".names").text(result.data.doctorName);
                if (localStorage.getItem("doctorId")!=null){
                    localStorage.removeItem("doctorId")
                }
                localStorage.setItem("doctorId",result.data.doctorId);

            }
        }).fail(()=>{
            alert("doctor/session request fail");
        });
        //退出登录
        $(".dropdown-container .form-content a").last().click(function () {
            //发送xhr
            $.getJSON("/doctor/logout",function (result) {
                //切换未登录状态
                $(".loginTop").css("display","block");
                $(".collapsible_menu").css("display","none");
            });
        });
    })
</script>
</html>